#!/bin/bash
# MSYS2 shell script to continuously watch ZooKeeper role check logs

echo "Starting continuous ZooKeeper role check log monitoring..."
echo "Press Ctrl+C to stop"
echo ""

while true; do
    timestamp=$(date '+%H:%M:%S')
    echo "=== $timestamp ==="
    
    # Get the latest pod
    pod=$(kubectl get pods -n zk -l app=zookeeper-role-check --sort-by=.metadata.creationTimestamp -o name | tail -1)
    
    if [ -n "$pod" ]; then
        kubectl logs -n zk "$pod"
    else
        echo "No pods found"
    fi
    
    echo ""
    sleep 60  # Wait 1 minutes
done